﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Services_ServiceGuest : System.Web.UI.Page
{
    ZSql zs = new ZSql();
    Function f = new Function();
    protected void Page_Load(object sender, EventArgs e)
    {
        txtKdate.Attributes.Add("onclick", "SelectDate('txtKdate')");
        txtJdate.Attributes.Add("onclick", "SelectDate('txtJdate')");
        if (!IsPostBack)
        {
            HidWareid.Value = getWareId();
            initData();
            lblPath.Text = f.getModuleidAdd(Request["moduid"]);
            lbljl.Text = (zs.GetScalar("select count(*) from CS_Mailadd where isadd=0 and ismail=1 and ispg=0")).ToString();
        }
    }

    private void initData()
    {
        ZSql zs = new ZSql();

        string sql = "select *,Convert(char(10),dispTime,120) as Date from CS_Mailadd where isadd=0 and ismail=1 and ispg=0  order by Maintaddid desc";
        PageNavigator1.Total = 1;
        PageNavigator1.Query = sql;
    }

    private string getWareId()
    {
        ZSql zs = new ZSql();
        string sql = "select WarehouseId from UserInfo where userid=" + Request.Cookies["user"].Values["id"];
        zs.Open(sql);

        zs.Close();
        return zs.m_table.Rows[0]["WarehouseId"].ToString();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string sql = "select *,Convert(char(10),dispTime,120) as Date from CS_Mailadd where isadd=0 and ismail=1 and ispg=0 ";
        if (!string.IsNullOrEmpty(txttel.Text))
        {
            sql += " and Guesttel like '%" + Common.FormatParameter(txttel.Text) + "%'";
        }
        if (!string.IsNullOrEmpty(txtmol.Text))
        {
            sql += " and comidSpe like '%" + Common.FormatParameter(txtmol.Text) + "%'";
        }
        if (!string.IsNullOrEmpty(txttype.Text))
        {
            sql += " and comitype like '%" + Common.FormatParameter(txttype.Text) + "%'";
        }
        if (!string.IsNullOrEmpty(txtband.Text))
        {
            sql += " and comidband like '%" + Common.FormatParameter(txtband.Text) + "%'";
        }
        if (!string.IsNullOrEmpty(txtadress.Text))
        {
            sql += " and Guestaddress like '%" + Common.FormatParameter(txtadress.Text) + "%'";
        }
        if (!string.IsNullOrEmpty(txtGuest.Text))
        {
            sql += " and Guestname like '%" + Common.FormatParameter(txtGuest.Text) + "%'";
        }
        if (!string.IsNullOrEmpty(txtKdate.Text) && !string.IsNullOrEmpty(txtJdate.Text.Trim()))
        {
            sql += " and dispTime >='" + Common.FormatParameter(txtKdate.Text) + " 00:00:00' and dispTime<='" + Common.FormatParameter(txtJdate.Text) + " 23:59:59'";
        }
        sql += " order by Maintaddid desc";
        PageNavigator1.Total = 1;
        PageNavigator1.Query = sql;

    }
    protected void linkedit_Click(object sender, EventArgs e)
    {
        string id = (sender as LinkButton).CommandArgument;
        Response.Redirect("Dispatch.aspx?moduid=" + Request["moduid"] + "&id="+id+"&action=yjsg");

    }

    protected void GvData_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        f.checkLevels(Request.Cookies["user"].Values["roleid"], Request["moduid"], 11, GvData);
       
    }
  
    protected void likadd_Click(object sender, EventArgs e)
    {
        Response.Redirect("Dispatch.aspx?moduid=" + Request["moduid"] + "");
    }
    protected void likypd_Click(object sender, EventArgs e)
    {
        Response.Redirect("ServiceGuestSale.aspx?moduid=" + Request["moduid"] + "");
    }
    protected void likyjsd_Click(object sender, EventArgs e)
    {
          Response.Redirect("ServiceGuestreamail.aspx?moduid=" + Request["moduid"] + "");
    }
    protected void likfwz_Click(object sender, EventArgs e)
    {
        Response.Redirect("ServiceGuestfwz.aspx?moduid=" + Request["moduid"] + "");
    }
    protected void likyjd_Click(object sender, EventArgs e)
    {
        Response.Redirect("ServiceGuestwc.aspx?moduid=" + Request["moduid"] + "");
    }
    protected void likall_Click(object sender, EventArgs e)
    {
        Response.Redirect("ServiceGuestqb.aspx?moduid=" + Request["moduid"] + "");
    }
}
